home *** CD-ROM | disk | FTP | other *** search
/ Collection of Tools & Utilities / Collection of Tools and Utilities.iso / bbsutil / bsrc_250.zip / B_TERMOV.C < prev    next >
C/C++ Source or Header  |  1991-09-15  |  9KB  |  240 lines

  1. /*--------------------------------------------------------------------------*/
  2. /*                                                                          */
  3. /*                                                                          */
  4. /*      ------------         Bit-Bucket Software, Co.                       */
  5. /*      \ 10001101 /         Writers and Distributors of                    */
  6. /*       \ 011110 /          Freely Available<tm> Software.                 */
  7. /*        \ 1011 /                                                          */
  8. /*         ------                                                           */
  9. /*                                                                          */
  10. /*  (C) Copyright 1987-91, Bit Bucket Software Co., a Delaware Corporation. */
  11. /*                                                                          */
  12. /*                                                                          */
  13. /*          This module was originally written by Vince Perriello           */
  14. /*                                                                          */
  15. /*                                                                          */
  16. /*                      BinkleyTerm Terminal Overlay                        */
  17. /*                                                                          */
  18. /*                                                                          */
  19. /*    For complete  details  of the licensing restrictions, please refer    */
  20. /*    to the License  agreement,  which  is published in its entirety in    */
  21. /*    the MAKEFILE and BT.C, and also contained in the file LICENSE.250.    */
  22. /*                                                                          */
  23. /*    USE  OF THIS FILE IS SUBJECT TO THE  RESTRICTIONS CONTAINED IN THE    */
  24. /*    BINKLEYTERM  LICENSING  AGREEMENT.  IF YOU DO NOT FIND THE TEXT OF    */
  25. /*    THIS  AGREEMENT IN ANY OF THE  AFOREMENTIONED FILES,  OR IF YOU DO    */
  26. /*    NOT HAVE THESE FILES,  YOU  SHOULD  IMMEDIATELY CONTACT BIT BUCKET    */
  27. /*    SOFTWARE CO.  AT ONE OF THE  ADDRESSES  LISTED BELOW.  IN NO EVENT    */
  28. /*    SHOULD YOU  PROCEED TO USE THIS FILE  WITHOUT HAVING  ACCEPTED THE    */
  29. /*    TERMS  OF  THE  BINKLEYTERM  LICENSING  AGREEMENT,  OR  SUCH OTHER    */
  30. /*    AGREEMENT AS YOU ARE ABLE TO REACH WITH BIT BUCKET SOFTWARE, CO.      */
  31. /*                                                                          */
  32. /*                                                                          */
  33. /* You can contact Bit Bucket Software Co. at any one of the following      */
  34. /* addresses:                                                               */
  35. /*                                                                          */
  36. /* Bit Bucket Software Co.        FidoNet  1:104/501, 1:343/491             */
  37. /* P.O. Box 460398                AlterNet 7:491/0                          */
  38. /* Aurora, CO 80046               BBS-Net  86:2030/1                        */
  39. /*                                Internet f491.n343.z1.fidonet.org         */
  40. /*                                                                          */
  41. /* Please feel free to contact us at any time to share your comments about  */
  42. /* our software and/or licensing policies.                                  */
  43. /*                                                                          */
  44. /*--------------------------------------------------------------------------*/
  45.  
  46. /* Include this file before any other includes or defines! */
  47.  
  48. #include "includes.h"
  49.  
  50. void ansi_map (unsigned ScanVal)
  51. {
  52.    unsigned KeyCode;
  53.   
  54.    int i;
  55.    int Len = 0;
  56.    char *Ptr = AnsiTbl;
  57.  
  58.    if (AnsiHdr->ElemCnt == 0)
  59.       return;
  60.  
  61.    for (i = 0; i < AnsiHdr->ElemCnt; i++)
  62.       {
  63.       KeyCode = *((unsigned int *)Ptr);
  64.       Ptr += sizeof (unsigned int);
  65.       Len = (int) *Ptr++;
  66.  
  67.       if (ScanVal == KeyCode)
  68.          break;
  69.  
  70.       Ptr += Len;
  71.       }
  72.  
  73.    if (i == AnsiHdr->ElemCnt)
  74.       return;
  75.  
  76.    SENDCHARS (Ptr, Len, 0);  /* Send the mapped string   */
  77. }
  78.  
  79. int term_overlay (int k)
  80. {
  81.    int c;
  82.    long t1;
  83.  
  84.          switch ((unsigned)k)
  85.             {
  86.             case F_TERM_SETBAUD:
  87.                ++baud;
  88.                if (!btypes[baud].rate_value)
  89.                   baud = 0;
  90.                program_baud ();
  91.                cur_baud = btypes[baud];
  92.                scr_printf (MSG_TXT(M_BINK_NOW_AT));
  93.                (void) sprintf (junk, "%u baud.\r\n", btypes[baud].rate_value);
  94.                scr_printf (junk);
  95.                break;
  96.  
  97.             case F_TERM_COMMCONFIG:
  98.                scr_printf ("\r\n7 or 8 data bits? ");
  99.                (void) fgets (junk, 100, stdin);
  100.                comm_bits = (atoi (junk) == 7) ? BITS_7 : BITS_8;
  101.                if (comm_bits == BITS_8)
  102.                   {
  103.                   parity = NO_PARITY;
  104.                   }
  105.                else
  106.                   {
  107.                   scr_printf ("(E)ven, (O)dd, or (N)o parity? ");
  108.                   (void) fgets (junk, 100, stdin);
  109.                   (void) strupr (junk);
  110.                   parity = (junk[0] == 'E') ? EVEN_PARITY :
  111.                      ((junk[0] == 'O') ? ODD_PARITY : NO_PARITY);
  112.                   }
  113.                scr_printf ("1 or 2 stop bits? ");
  114.                (void) fgets (junk, 100, stdin);
  115.                stop_bits = (atoi (junk) == 1) ? STOP_1 : STOP_2;
  116.  
  117.                program_baud ();
  118.                break;
  119.  
  120.             case F_TERM_DIALOUT:
  121.                scr_printf (MSG_TXT(M_PHONE_OR_NODE));
  122.                if (!get_number (junk))
  123.                   break;
  124.                if (strchr (junk, '/') != NULL)
  125.                   {
  126.                   if (nodeproc (junk))
  127.                      {
  128.                      (void) strcpy (junk, (char *) (newnodedes.PhoneNumber));
  129.                      do_dial_strings ();
  130.                      }
  131.                   else break;
  132.                   }
  133.                try_2_connect (junk);             /* try to connect         */
  134.                gong ();
  135.                break;
  136.  
  137.             case F_TERM_CLEARSCREEN:
  138.                screen_clear ();
  139.                break;
  140.  
  141.             case F_TERM_HANGUP:
  142.                t1 = timerset (300);
  143.                while (CARRIER)
  144.                   if (timeup (t1))
  145.                      {
  146.                      scr_printf (MSG_TXT(M_NO_DROP_DTR));
  147.                      break;
  148.                      }
  149.                   else
  150.                      {
  151.                      LOWER_DTR ();
  152.                      }
  153.                status_line (MSG_TXT(M_END_OF_CONNECT));
  154.                RAISE_DTR ();
  155.                break;
  156.  
  157.             case F_TERM_REINITMODEM:
  158.                mdm_init (term_init);
  159.                break;
  160.  
  161.             case F_TERM_SHELL:
  162.                scr_printf ("\r\n");
  163.                scr_printf (&(MSG_TXT(M_SHELLING)[1]));
  164.                scr_printf (MSG_TXT(M_TYPE_EXIT));
  165.                MDM_DISABLE ();
  166.                change_prompt ();
  167.                b_spawn (NULL);
  168.                /* Re-enable ourselves */
  169.                if (Cominit (port_ptr, buftmo) != 0x1954)
  170.                   {
  171.                   (void) printf ("\r\n%s\r\n", MSG_TXT(M_FOSSIL_GONE));
  172.                   exit (1);
  173.                   }
  174.                scr_printf (MSG_TXT(M_WELCOME_BACK));
  175.                RAISE_DTR ();
  176.                program_baud ();
  177.                break;
  178.  
  179.             case F_TERM_CHANGEPORT:
  180.                c = port_ptr;
  181.                if (++port_ptr == MAXport)
  182.                   port_ptr = 0;
  183.                MDM_DISABLE ();
  184.                if (Cominit (port_ptr, buftmo) != 0x1954)
  185.                   {
  186.                   port_ptr = c;
  187.                   (void) Cominit(port_ptr, buftmo);
  188.                   }
  189.                program_baud ();
  190.                RAISE_DTR ();
  191.                scr_printf (MSG_TXT(M_BINK_NOW_USING));
  192.                WRITE_ANSI ((char)(port_ptr + '1'));
  193.                scr_printf (":\r\n");
  194.                XON_ENABLE ();
  195.                break;
  196.  
  197.             case F_TERM_DOBREAK:
  198.                if (old_fossi